/*******************************************************************
 *   > File Name: buzzer.c
 *   > Author: fly
 *   > Mail: XXXXXXXX@icode.com
 *   > Create Time: 2020年04月28日 星期二 10时01分12秒
 ******************************************************************/
#include <types.h>
#include <io.h>
#include <s5pv210/reg-gpio.h>

/*
 * speader enable: GPD0_2
 * 初始化GPIO口
 */
void speaker_init(void)
{
        writel(S5PV210_GPD0CON, (readl(S5PV210_GPD0CON) & ~(0xf<<8)) | (0x1<<8));
        writel(S5PV210_GPD0PUD, (readl(S5PV210_GPD0PUD) & ~(0x3<<4)) | (0x2<<4));
        writel(S5PV210_GPD0DAT, (readl(S5PV210_GPD0DAT) & ~(0x1<<2)) | (0x0<<2));
}

/*
 * 蜂鸣器使能函数，on=1：蜂鸣  on=0：停止蜂鸣
 */
void speaker_set(int on)
{
    if(on)
        writel(S5PV210_GPD0DAT, (readl(S5PV210_GPD0DAT)&~(0x1<<2))|(0x1<<2));
    else
        writel(S5PV210_GPD0DAT, (readl(S5PV210_GPD0DAT)&~(0x1<<2))|(0x0<<2));
}
